import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

Vue.use(VueRouter)
 
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/carry',
    name: 'Carry',
    component: () => import('../views/useComputer.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/Register.vue')
  },
  {
    path: '/home',
    name: 'Home',
    component: () =>import('../views/Home.vue'),
    children: [
      {
        path: '/users',
        name: 'Users',
        component: () =>import('../components/Usertab.vue')
      },
      {
        path: '/loophole',
        name: 'Loophole',
        component: () =>import('../components/Loophole.vue')
      },
      {
        path: '/statistics',
        name: 'Statistics',
        component: () =>import('../components/Statistics.vue')
      },
      {
        path: '/servertab',
        name: 'Servertab',
        component: () =>import('../components/Servertab.vue')
      },
      {
        path: '/loopholedeal',
        name: 'Loopholedeal',
        component: () =>import('../components/loopholedeal.vue')
      }
    ],
    redirect: '/statistics'
  },
]

const router = new VueRouter({
  mode:'hash',
  routes
})

export default router
